//
//  ViewController.m
//  简易计算器 16.3.1
//
//  Created by zhangxin on 16/3/1.
//  Copyright © 2016年 zhangxin. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)method
{
    
    NSString * text1 = self.textField1.text;
    NSString * text2 = self.textField2.text;
    
    int num1 = [text1 intValue];
    int num2 = [text2 intValue];
    int result = 0 ;
    NSString * yunsuanfu = self.pl.text;
    char ysf = [yunsuanfu characterAtIndex:0];
    switch (ysf) {
        case '+':
            result = num1+num2;
            break;
           
        case '-':
            result = num1-num2;
            break;
           
        case '*':
            result = num1*num2;
            break;
           
        case '/':
            result = num1/num2;
            break;
    }
    
    
    NSString * output = [NSString stringWithFormat:@"%d",result];
    self.res.text = output;
    
    
    
    NSLog(@"计算按钮被点击了");
    NSLog(@"%@",text1);
    NSLog(@"%@",text2);
    NSLog(@"%d",result);
}

- (IBAction)plus
{
    self.pl.text = @"+";
}

- (IBAction)jian
{
    self.pl.text = @"-";
}

-(IBAction)cheng
{
    self.pl.text = @"*";
}

- (IBAction)chu
{
    self.pl.text = @"/";
}
@end
